import request from "@/utils/request";
import axios from "axios";

/**
 * 上传附件
 * @param {FormData} data - 包含文件和其他参数的FormData对象
 * @returns {Promise} - 返回上传结果的Promise
 */
export function uploadAttachment(data) {
  return axios.post("http://60.205.171.41:18889/upload", data, {
    headers: {
      "Content-Type": "multipart/form-data",
    },
  });

  // return request({
  //   url: "/upload",
  //   method: "post",
  //   data,
  //   headers: {
  //     "Content-Type": "multipart/form-data",
  //   },
  // });
}

/**
 * 与模型对话
 * @param {JSON} data
 * @returns {Promise} - 返回上传结果的Promise
 */
export function chat(data) {
  return request({
    url: "/chat",
    method: "post",
    data,
    timeout: 10 * 60 * 1000,
    responseType: "stream",
    headers: {
      Accept: "text/event-stream",
    },
  });
}
